using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PhysicsCheck : MonoBehaviour
{
    public bool onGround;
    public bool onWall;
    public bool onStair;
    [Header("检测相关")]
    public Vector2 offset;
    public Vector2 stairOffset;
    public float radius;
    public Vector2 stairSize;
    [SerializeField] private LayerMask ground;
    [SerializeField] private LayerMask stair;
    [SerializeField] private LayerMask wall;
    
    
    private Vector2 faceDir;

    private void Update()
    {
        faceDir = transform.localScale;
        Check();
    }

    private void Check()
    {
        onGround = Physics2D.OverlapCircle((Vector2)transform.position + offset * faceDir, radius, ground);
        onStair = Physics2D.OverlapBox((Vector2)transform.position + stairOffset * faceDir, stairSize, 360, stair);
    }

    private void OnDrawGizmosSelected()
    {
        Gizmos.DrawWireSphere((Vector2)transform.position + offset * faceDir, radius);
        Gizmos.DrawWireCube((Vector2)transform.position + stairOffset * faceDir, stairSize);
    }
}
